package com.eclink.asset.web.controller;

import com.cyl.wms.convert.AssetAuditConfigConvert;
import com.cyl.wms.domain.AssetAuditConfig;
import com.cyl.wms.pojo.query.AssetAuditConfigQuery;
import com.cyl.wms.service.AssetAuditConfigService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资产入库Controller
 *
 * @author zcc
 * @date 2024-06-04
 */
@Api(description ="资产入库申请接口列表")
@RestController
@RequestMapping("/asset/inApply")
public class InApplyController extends BaseController {

    @Autowired
    private AssetAuditConfigService service;

    @Autowired
    private AssetAuditConfigConvert convert;

    @ApiOperation("查询资产审批配置列表")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfig:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<AssetAuditConfig>> list(@RequestBody AssetAuditConfigQuery query, Pageable page, Integer configType) {
        List<AssetAuditConfig> list = service.selectList(query, page, configType);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("获取资产审批配置详细信息")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfig:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<AssetAuditConfig> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增资产审批配置")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfig:add')")
    @Log(title = "资产审批配置", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody AssetAuditConfig assetAuditConfig) {
        return ResponseEntity.ok(service.insert(assetAuditConfig));
    }

    @ApiOperation("修改资产审批配置")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfig:edit')")
    @Log(title = "资产审批配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody AssetAuditConfig assetAuditConfig) {
        return ResponseEntity.ok(service.update(assetAuditConfig));
    }

    @ApiOperation("删除资产审批配置")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfig:remove')")
    @Log(title = "资产审批配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
